package com.yundasys.lab02springbootstudy.boot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.support.ResourcePropertySource;

import java.io.IOException;

/**
 * @author jiangta
 * @version 1.0
 * @date 2022/4/1 2:48 下午
 */
public class Step6 {

    public static void main(String[] args) throws IOException {
        SpringApplication app = new SpringApplication();

        StandardEnvironment environment = new StandardEnvironment();
        environment.getPropertySources().addLast(new ResourcePropertySource("step4", new ClassPathResource("step4.properties")));

        User user = Binder.get(environment).bind("user",User.class).get();
        System.out.println(user);

    }

    static class User {
        private String firstName;

        private String middleName;
        private String lastName;

        public String getFirstName() {
            return firstName;
        }

        public void setFirstName(String firstName) {
            this.firstName = firstName;
        }

        public String getMiddleName() {
            return middleName;
        }

        public void setMiddleName(String middleName) {
            this.middleName = middleName;
        }

        public String getLastName() {
            return lastName;
        }

        public void setLastName(String lastName) {
            this.lastName = lastName;
        }
    }
}
